//
//  ZJCourseIntroView.m
//  ZhongWangYuanApp
//
//  Created by ZJ on 2018/6/2.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "ZJCourseIntroView.h"

@interface ZJCourseIntroView ()

/** title */
@property (nonatomic, strong) UILabel *titleLabel;
/** 内容 */
@property (nonatomic, strong) UILabel *contentLabel;
@end

@implementation ZJCourseIntroView

- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initUIWithTitle:title];
    }
    return self;
}

- (void)initUIWithTitle:(NSString *)title{
    self.backgroundColor = [UIColor themeWhiteColor];
    [self addSubview:self.titleLabel];
    [self addSubview:self.contentLabel];
    
    self.titleLabel.sd_layout
    .topSpaceToView(self, 12 * [UIScreen zj_screenHScale])
    .leftSpaceToView(self, 12 * [UIScreen zj_screenWScale])
    .widthIs([UIScreen zj_screenWith] - 24 * [UIScreen zj_screenWScale])
    .heightIs([NSString heightWithTextFont:self.titleLabel.font]);
    
    self.contentLabel.sd_layout
    .topSpaceToView(self.titleLabel, 15 * [UIScreen zj_screenHScale])
    .leftEqualToView(self.titleLabel)
    .widthIs([UIScreen zj_screenWith] - 24 * [UIScreen zj_screenWScale])
    .heightIs(10);
    
    [self setupAutoHeightWithBottomView:self.contentLabel bottomMargin:12 * [UIScreen zj_screenHScale]];
    self.titleLabel.text = title;
}

- (void)setContentLabelText:(NSString *)text{
    self.contentLabel.keywordsColor = self.backgroundColor;
    NSString *comment = [NSString stringWithFormat:@"尚錕%@",[NSString  string:text isNilStringReturnDeftString:@"暂无简介"]];
    self.contentLabel.text = comment;
    self.contentLabel.sd_layout
    .topSpaceToView(self.titleLabel, 15 * [UIScreen zj_screenHScale])
    .leftEqualToView(self.titleLabel)
    .widthRatioToView(self.titleLabel, 1)
    .heightIs([self.contentLabel getLableSizeWithMaxWidth:self.contentLabel.width].height);    [self.contentLabel updateLayout];
}
#pragma mark - getter
- (UILabel *)titleLabel{
    if (_titleLabel == nil){
        _titleLabel = [UILabel new];
        _titleLabel.textColor = [UIColor zj_colorWithHexString:@"626262"];
        _titleLabel.font = LYPBOLDFONT(18);
    }
    return _titleLabel;
}
- (UILabel *)contentLabel{
    if (_contentLabel == nil){
        _contentLabel = [UILabel new];
        _contentLabel.textColor = [UIColor zj_colorWithHexString:@"626262"];
        _contentLabel.font = LYPFONT(15);
        _contentLabel.keywordsArray = @[@"尚錕"];
        _contentLabel.keywordsFont = _contentLabel.font;
        _contentLabel.numberOfLines = 0;
        _contentLabel.characterSpace = 1;
        _contentLabel.lineSpace = 8 * [UIScreen zj_screenHScale];
        
    }
    return _contentLabel;
}

@end
